import request from '@/utils/request'

/**
 * 获取流程信息
 * @param returnId
 * @returns {*}
 */
export function getAllocation(returnId) {
  return request({
    url: '/cloud/jcce/v1.0/kt2/getAllocation',
    method: 'get',
    params: {
      returnId: returnId
    }
  })
}

/**
 * 获取流程配置信息
 * @param returnId
 * @returns {*}
 */
export function getConfiguration(processId, target) {
  return request({
    url: '/cloud/jcce/v1.0/kt2/getConfiguration',
    method: 'get',
    params: {
      processId: processId,
      target: target
    }
  })
}

import bpmnModal from '../bpmnModal.vue'

export default {
  name: 'bpmn',
  components: {
    bpmnModal
  },
  data() {
    return {
      isLoading: false,
      returnId: '',
      dqtc: '短期套餐',
      tableData: [],
      escalationData: {
        processId: '',
        target: ''
      }
    }
  },
  mounted() {
    this.initXml()
  },
  methods: {
    initXml() {
      getAllocation(this.returnId).then((data) => {
        this.escalationData.processId = data.data.id
        this.$refs.modal.import(data.data.processData)
      }).catch((error) => {
        console.log(error)
      })
    },
    getData() {
      getConfiguration(this.escalationData.processId, this.escalationData.target).then((data) => {
        this.tableData = data.data
        this.isLoading = false
      }).catch((error) => {
        console.log(error)
        this.isLoading = false
      })
    },
    handleRadioChange(value) {
      this.isLoading = true
      this.escalationData.target = value
      this.getData(value)
    }
  }
}
